package com.atguigu.tingshu.album.client;

import com.atguigu.tingshu.album.service.TrackInfoService;
import com.atguigu.tingshu.common.login.GuiguLogin;
import com.atguigu.tingshu.model.album.TrackInfo;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/***
 * 声音内部调用接口
 */
@RestController
@RequestMapping(value = "/client/track/trackInfo")
public class TrackInfoClientController {

    @Autowired
    private TrackInfoService trackInfoService;


    /**
     * 查询声音的详细信息,和可以购买的声音的列表
     * @param trackId
     * @return
     */
    @GuiguLogin
    @GetMapping(value = "/trackInfo/{trackId}/{trackCount}")
    public List<TrackInfo> trackInfo(@PathVariable(value = "trackId") Long trackId,
                                     @PathVariable(value = "trackCount") Integer trackCount){
        return trackInfoService.getTrackInfoList(trackId, trackCount);
    }

    /**
     * 查询声音的详细信息
     * @param trackId
     * @return
     */
    @GetMapping(value = "/getTrackInfo/{trackId}")
    public TrackInfo getTrackInfo(@PathVariable(value = "trackId") Long trackId){
        return trackInfoService.getById(trackId);
    }
}
